<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	    <table style="width:100%;">
	        <tr>
	            <td style="width:100%;"></td>
	            <td style="white-space:nowrap;">
	            	<span>药品名称（模糊）：</span>
	                <input id="medicineName" class="mini-textbox" emptyText="请输入药品名称" style="width:100px;" />   
	            	<span>药品类型：</span>
	            	<input id="medicineType" emptyText="请选择..." showNullItem="true" nullItemText="全部" class="mini-combobox" valueField="keyName" style="width: 100px" textField="keyValue" url="dictionary_wm_key_val_view.do?typeName=MEDICINE_TYPE" />
	                <span>仓库名称（模糊）：</span>
	                <input id="warehouseName" class="mini-textbox" emptyText="请输入仓库名称" style="width:100px;" />   
	            </td>
	            <td style="white-space:nowrap;">
                	<a class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
                </td>
	        </tr>
	    </table>
	</div>
	<div class="mini-fit" >
	<div id="datagrid1" class="mini-datagrid " idField="id" pageSize="20" url="in_stock_view.do" style="width:100%;height:100%;" multiSelect="true">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div name="action" width="10%" headerAlign="center" align="center" renderer="onActionRenderer">相关操作</div>
			<div field="medicineName" width="20%" headerAlign="center" align="center">药品名称</div>
			<div field="medicineUnit" width="10%" headerAlign="center" align="center">单位</div>
			<div field="quantity" width="20%" headerAlign="center" align="center">数量</div>
			<div field="medicineTypeValue" width="20%" headerAlign="center" align="center">类型</div>
			<div field="warehouseName" width="20%" headerAlign="center" align="center">仓库</div>
		</div>
	</div>
	</div>

<script type="text/javascript">
	mini.parse();
	
	var grid = mini.get("datagrid1");
	grid.load();

	function search(){
		 var medicineName = mini.get("medicineName").getValue();
	     var warehouseName = mini.get("warehouseName").getValue();
	     var medicineType = mini.get("medicineType").getValue();
	     
       grid.load({ 
    	   medicineName: medicineName,
       	   warehouseName: warehouseName,
       		medicineType: medicineType
       });
	}
	
    //相关操作
    function onActionRenderer(e) {
	    var s = '<a href="javascript:changeView()">库存变化记录</a>';
	    return s;
    }
    
    function changeView(){
    	var row = grid.getSelected();
    	mini.open({
	        url: "medicine_num_change.do",
	        allowResize:false,
	        title: "库存变化记录", width: 800, height: 450,
	        onload: function () {
	            var iframe = this.getIFrameEl();
	            iframe.contentWindow.SetData(row);
	        },
	        ondestroy: function (action) {
	        	if(action == 'succ'){
	        		mini.showMessageBox({
	                    title: "提示",
	                    showModal:false,
	                    iconCls: "mini-messagebox-warning",
	                    message: "保存成功！",
	                    timeout: 3000,
	                    x: 'right',
	                    y: 'bottom'
	                });
		            grid.reload();
	        	}
	        }
	    });
    }
</script>
</body>
</html>